﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ConferenceZoom.Models
{
    /// <summary>
    /// The interface between the web application and the real meat - things we have
    /// to deal with...
    /// </summary>
    public class ConferenceInterface
    {
        /// <summary>
        /// Given the URL of a string, does its best to parse it and return a unique
        /// string that can be used to identify the conference (though perhaps not re-create
        /// the whole URL!!).
        /// 
        /// Returns NULL if it can't do the conversion.
        /// 
        /// </summary>
        /// <param name="url">URL of the string</param>
        /// <returns></returns>
        public static string ConvertURLToUniqueID(string url)
        {
            ///
            /// We only do the indico guys right now, so we just do our best!
            /// 

            try
            {
                IndicoInterface.AgendaInfo agenda = new IndicoInterface.AgendaInfo(url);
                return agenda.AgendaSite + "-" + agenda.ConferenceID;
            }
            catch (Exception)
            {
                return null;
            }
        }
    }
}
